import React,{Component} from 'react'
import $ from 'jquery'
import * as echarts from 'echarts';


export default class Text extends Component {
    componentDidMount() {
        var myChart = echarts.init(document.getElementById("myCharts"))
        myChart.showLoading({
            text: '正在努力加载中...'
        });
        myChart.setOption( {
            toolbox : {
                show : true,
                feature : {
                    mark : {show: false},
                    dataView : {show: false, readOnly: false},
                    magicType : {
                        show: true,
                        type: ['pie', 'funnel'],
                        option: {
                            funnel: {
                                x: '25%',
                                width: '50%',
                                funnelAlign: 'left',
                                max: 1548
                            }
                        }
                    },
                    restore : {show: false},
                    saveAsImage : {show: false}
                }
            },
            calculable : false,
            tooltip : {
                trigger: 'item',
                formatter: "{a} <br/>{b} : {c} ({d}%)"
            },
            legend: {
                left: 'right',
                data: []
            },
            series : [
                {
                    name: '访问来源',
                    type: 'pie',
                    radius : '55%',
                    center: ['50%', '60%'],
                    data:[
                        {}
                    ],
                    itemStyle: {
                        emphasis: {
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        }
                    }
                }
            ]
        });
        //  var param = {};
        // $.ajax({
        //     "type": 'post',
        //     "url": "http://127.0.0.1:8088/allHttp",
        //     "sync": true,
        //     "dataType": "json",
        //     "data":param,
        //     "success": function (result) {
        //         var ds = result.aaData;
        //         var options = myChart.getOption();
        //         options.series[0].data = ds.series;
        //         myChart.hideLoading();
        //         myChart.setOption(options);
        //
        //     }
        // });
    }
    render() {
        return (
            <div id="myCharts" style={{width: "100%", height: 500}}>
            </div>
        )
    }
}
